<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 25/05/11
 * Time: 15:03
 * To change this template use File | Settings | File Templates.
 */

class UrlDecoder
{


    private static $decoded = false;


    private static $Controller_Name;
    private static $Action_Name;
    private static $params = array();


    public static function decode(){
        $uri = explode('/',substr( $_SERVER['QUERY_STRING'],3));
        if(isset($uri[0]))       {
            self::$Controller_Name = $uri[0];
            if(isset($uri[1]))  {
                self::$Action_Name = $uri[1];
                for($i=2;$i<sizeof($uri);$i++){
                    self::$params[] = $uri[$i];
                }
            }
        }
        self::$decoded = true;
    }


    public static function get_Controller_Name()
    {
        if (!self::$decoded)
            self::decode();
        return self::$Controller_Name;
    }

    public static function get_Action_Name()
    {
        if (!self::$decoded)
            self::decode();
        return self::$Action_Name;
    }

    public static function get_Params()
    {
        if (!self::$decoded)
            self::decode();
        return self::$params;
    }


}
